/*
 
 =============================================================================
 
 Copyright (c) 2010 Xiotex Studios Ltd.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The end-user documentation included with the redistribution, if any, must
 include the following acknowledgment: "This product includes software
 developed by Xiotex Studios Ltd (http://xiotexstudios.com)", in the same
 place and form as other third-party acknowledgments. Alternately, this
 acknowledgment may appear in the software itself, in the same form and
 location as other such third-party acknowledgments.
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. 
 
 =============================================================================
 
 File:			iPhoneSWFLog.cpp
 Author:		(Ola)dotun Rominiyi
 
 Update(s):	
 
 =============================================================================
 
 */


#include "SWFBase.h"
#include "SWFLog.h"

#include <signal.h>
#include <stdarg.h>
#include <stdio.h>

char* gpAssertFilename = NULL;
int gAssertLineNumber = 0;

void CSWFAssertFunction(const char* pcondition, const char* pfilename, const sInt32 line )
{
	printf("\n");	
	printf(" *** ASSERTION FAILED ***\n\n");
	printf(" Condition : %s\n",pcondition);
	printf(" File      : %s\n",pfilename);
	printf(" Line      : %d\n",line);	
	printf("\n");
	
	// Exit the Program ( Abort )
	raise(SIGABRT);
	exit(3);
}

void CSWFAssertMsgFunction(bool condition, const char* msg, ... )
{
	if ( condition != false )
		return;
	
	const int cMsgTxtLen = 256;
	char szMsgTxt[cMsgTxtLen];
	
	va_list arglist;
	va_start(arglist, msg);
	{
		sprintf( szMsgTxt, msg, arglist );
	}
	va_end(arglist);
	
	printf("\n");	
	printf(" *** ASSERTION FAILED ***\n\n");
	printf(" File      : %s\n",gpAssertFilename);
	printf(" Line      : %d\n",gAssertLineNumber);
	printf(" Message   : %s\n",szMsgTxt);		
	printf("\n");
	
	// Exit the Program ( Abort )
	raise(SIGABRT);
	exit(3);
}

